package inner;

/**
 * Created with IntelliJ IDEA
 * Description:静态内部类学习
 * User:22954
 * Date:2024-01-07
 * Time:15:55
 */
class Outer1{
    public int data1=1;
    int data2=2;
    static int data3=3;
    static class Inner1{
        public int data4=4;
        int data5=5;
        static int data6=6;
        public void fuc(){
            //System.out.println(data1); //静态内部类只能访问外部类的静态成员变量
            Outer1 outer1=new Outer1();
            System.out.println(outer1.data1);//只能通过这种方式访问

            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
        public static void fuc1(){
            System.out.println(data3);
            //System.out.println(data4); //嵌套，编译错误的原因同之前一样
            //System.out.println(data5);
            System.out.println(data6);
        }
    }
}
public class Test2 {
    public static void main(String[] args) {
        Outer1.Inner1 inner1=new Outer1.Inner1();
        inner1.fuc();
        Outer1.Inner1.fuc1();
    }
    public static void main1(String[] args) {
        System.out.println(Outer1.Inner1.data6);
        Outer1.Inner1 inner1=new Outer1.Inner1();
        System.out.println(inner1.data5);
    }
}
